<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<style>
    html{background-color: #FFFFFF;}
    body{width: 100%;height: 100%}
    .conindex{padding: 20px 20px;background-color: #FFFFFF;width: calc(100% - 40px);;height: calc(100% - 40px);background:url(/static/admin/images/huan.png);background-size:100% 100%;background-repeat:no-repeat;}
    .layui-table-tool,.layui-table-page{display: none}
    .layui-table-view{height: 220px!important;}
    .gao{background-color: rgba(255,255,255,0.8);height: 280px;width:calc(100% - 40px);padding: 0 20px;border-radius: 5px}
    .gao .tits{height: 40px;line-height: 40px}
    .laytp-container .layui-card-body{margin: 0}

    .xia{background-color: rgba(255,255,255,0.8);height: 200px;width:50%;padding: 0 20px;border-radius: 5px;margin-top: 30px}
    .xia .tits{height: 40px;line-height: 40px}
    .xia .xiabox{width: calc(25% - 15px);margin-right: 20px;height: 130px;background-color: #FFFFFF;border-radius: 5px;float: left}
    .xia .xiabox:hover{background-color: #daf0ff;}
    .xia .xiabox_yue{margin-right: 0}
    .xia .xiabox .tt{padding: 10px 0 0 15px;font-weight: 700}
    .xia .xiabox .mm{padding-top: 30px;font-weight: 700;font-size: 20px;text-align: center}
    .huanlogo{position: fixed;bottom: 70px;text-align: right;width: 100%;right: 20px}
    #subbutss{position: absolute;top: 2px;right: -65px}
</style>
<body class="laytp-container">
<div class="conindex">
    <div class="layui-card" id="table-card">
        <div class="gao">
            <div class="tits">
                <span class="colorlan" style="float: left"><b>文件上报</b></span>
                <span style="float: left">（点击项目名称进入）</span>
                <div class="layui-col-md6" style="width: 500px">
                    <div class="layui-input-block" style="z-index: 1;margin-left: 20px">
                        <input type="text" name="areas" id="areas" placeholder="请选择区域" readonly clearable autocomplete="off" class="layui-input">
                        <button class="laytp-btn laytp-btn-md laytp-btn-primary" type="button" id="subbutss"><i class="layui-icon layui-icon-search"></i>查询</button>
                    </div>

                </div>
                <span class="colorlan" style="float: right" onclick="auth_but_func_engin_more()"><b>更多</b></span>
            </div>
            <div class="layui-col-md12" style="border: 1px solid #eee">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
        <div class="xia layui-hide" id="shendai">
            <div class="tits">
                <span class="colorlan"><b>审批待办</b></span>
            </div>
            <div>
                <div class="xiabox xiabox_bao layui-hide" onclick="auth_but_func_shen_bao()"><div class="tt">文件待审</div><div class="mm colorlan">0</div></div>
                <div class="xiabox xiabox_shi layui-hide" onclick="auth_but_func_shen_shi()"><div class="tt">施工日志</div><div class="mm colorlan">0</div></div>
                <div class="xiabox xiabox_jian layui-hide" onclick="auth_but_func_shen_jian()"><div class="tt">监理日志</div><div class="mm colorlan">0</div></div>
                <div class="xiabox xiabox_yue layui-hide" onclick="auth_but_func_shen_yue()"><div class="tt">进度月报</div><div class="mm colorlan">0</div></div>
            </div>
        </div>

        <div class="huanlogo"><img src="/static/admin/images/huanlogo.png"></div>
    </div>
</div>



<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>
    var areasFirst = 0;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        ajax_func_engin();
        ajax_func_shen();
        setInterval(function(){
            ajax_func_engin();
            ajax_func_shen();
        },120000);

        $("#subbutss").click(function () {
            var areas = $("#areas").val();
            ajax_func_engin(areas);
        });

        function ajax_func_engin(areas='') {
            var mytable = table.render({
                elem: "#datalist",id: "datalist"
                ,url: facade.url(ask_home_engin_list),where: {areas:areas}, page: false, height: 260
                ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
                ,defaultToolbar: [],filter: TabInit.filter
                ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
                ,text: TabInit.text
                ,parseData: function (res) {


                    if(areasFirst < 1){
                        load_areas('areas', res.data.areas, 3);
                        areasFirst = 1;
                    }


                    return {
                        "code": res.code,
                        "msg": res.message,
                        "count": res.data.total,
                        "data": res.data.data
                    };
                }
                , cols: [[
                    {type:'numbers',title:'工程序号',fixed:'left',width:80}
                    ,{field: 'state_name', title: '项目状态',width:120}
                    ,{field:'name',title:'项目名称',templet: function(d){
                            return '<span class="colorlan" onclick="openPage(\'../engin_bao/list.php?id='+d.id+'\')">'+d.name+'</span>';
                        }}
                    ,{field: 'number', title: '项目编号',width:120}
                    ,{field: 'engintype', title: '项目类型',width:120}
                    ,{field:'hemoney',title:'合同金额(元)',width:150,align:'right',templet: function(d){
                            return '<span class="">'+parseFormatNum(d.hemoney)+'</span>';
                        }}
                    ,{field:'chanfee',title:'已完成工程量金额(元)',width:150,align:'right',templet: function(d){
                            return '<span class="">'+parseFormatNum(d.chanfee)+'</span>';
                        }}
                    ,{field: 'areas', title: '项目地点',width:150}
                    ,{field: 'planstartdt', title: '合同计划开工日期',width:120}
                    ,{field: 'startdt', title: '实际开工日期',width:120}
                    ,{field: 'planenddt', title: '合同计划竣工日期',width:120}
                    ,{field: 'enddt', title: '实际竣工日期',width:120}
                ]]
                , done: function (res) {
                    soulTable.render(this);
                }
            });
        }


        function ajax_func_shen() {
            facade.ajax({url: ask_home_shen_list}).done(function(res){
                if (res.code === 2000) {
                    if(res.data.isshow){
                        $("#shendai").removeClass('layui-hide');
                        $("#shendai .xiabox").addClass('layui-hide');

                        var list = res.data.list;
                        for (var key in list){
                            $("#shendai .xiabox_"+list[key].name).removeClass('layui-hide');
                            $("#shendai .xiabox_"+list[key].name+" .mm").html(list[key].num)
                        }
                    }else{
                        $("#shendai").addClass('layui-hide');
                    }
                    render_from();
                }
            });
        }



    });


    function auth_but_func_engin_more(){
        openNavPage('文件上报','engin_bao/index.php');
    }


    function auth_but_func_shen_bao(){
        openNavPage('文件上报','shen_bao/index.php');
    }
    function auth_but_func_shen_shi(){
        openNavPage('施工日志','shen_shi/index.php');
    }
    function auth_but_func_shen_jian(){
        openNavPage('监理日志','shen_jian/index.php');
    }
    function auth_but_func_shen_yue(){
        openNavPage('进度月报','shen_yue/index.php');
    }
</script>
</body>
</html>
